package com.greedy;

public class Solution08 {
    public int jump(int[] nums) {
        if (nums.length == 1) return 0;
        int count = 0;
        int cover = 0;
        int tmp = 0;
        for (int i = 0; i <= cover; i++) {
            tmp =  Math.max(tmp,i+nums[i]);
            if (tmp >= nums.length-1) {
                count++;
                return count;
            }
            if (i == cover ) {
                cover = tmp;
                count++;
            }
        }
        return count;
    }
}
